package gui5e;

import java.util.Map;

import processing.core.PApplet;
import controlP5.*;

public class BottomPanel extends Panel{

		//constructors
		public BottomPanel(int s_, int pr_, PApplet pa_, ControlP5 c_){
			super(s_, pr_, pa_);
			  ctrl = c_;
			  accordion =  ctrl.addAccordion("acc_b");
			  y=pa_.getHeight() -  GUI.panelBottomHeight;
		}
		
		//methods
		
		/// the update method for the panel
		public void draw(PApplet p_){
			if(!isExisting){
				 for (Map.Entry<String, Group> entry : ctrlGroups.entrySet()) {
					    Group group_ = entry.getValue();
					    accordion.addItem(group_)
					    	.setPosition((x+10), y +20)
					    	.setWidth(GUI.panelBottomHeight - 20)
					    	;
					}
				  {{accordion.open(1);}};
				isExisting=true;
			}
				if(!isWaiting){
				//size&position  
				switch(mode_){
				  case 's': if(y> p_.getHeight()-GUI.panelBottomHeight)  y = y - GUI.PanelSpeed; else mode_ = 'v';break;
				  case 'h': if(y< p_.getHeight()) y = y + GUI.PanelSpeed; else mode_ = 'm';break;
				  case 'v': y=p_.getHeight() -  GUI.panelBottomHeight; break;
				  case 'm': y=p_.getHeight(); break;
				 } 
				//background
				p_.fill(GUI.backgroundPanel[0],GUI.backgroundPanel[1],GUI.backgroundPanel[2], GUI.backgroundPanel[3]);
				if(GUI.borderPanel.length < 2) p_.noStroke(); else p_.stroke(GUI.borderPanel[0],GUI.borderPanel[1],GUI.borderPanel[2], GUI.borderPanel[3]);
				GUI.innerHeight =  y - GUI.innerTop;
				p_.rect(x, y, p_.getWidth(), GUI.panelBottomHeight);	  
				//toolboxes
				ctrl.draw();
				accordion.setPosition(20, y+20);
				}	    
			}
	
}
